package com.lj.sys.result;

import com.lj.sys.entity.SysDept;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 系统部门表 信息结果
 * </p>
 *
 * @author luojing
 * @since 2024-12-20 21:27:32
 */
@Data
@Schema(description = "系统部门表 信息结果")
public class SysDeptInfoResult {

    private Long id;

    @Schema(description = "部门名称 ")
    private String deptName;

    @Schema(description = "父部门 ")
    private Long parentId;

    private String remark;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    @Schema(description = "子部门")
    private List<SysDeptInfoResult> children = new ArrayList<>(0);

    public static SysDeptInfoResult of(SysDept entity) {
        if (entity == null) {
            return null;
        }
        SysDeptInfoResult result = new SysDeptInfoResult();
        result.setId(entity.getId());
        result.setDeptName(entity.getDeptName());
        result.setParentId(entity.getParentId());
        result.setRemark(entity.getRemark());
        result.setCreateTime(entity.getCreateTime());
        result.setUpdateTime(entity.getUpdateTime());
        return result;
    }
}
